--[[
	ALL SPECS
]]
function ccR_DeathKnight_RisenAlly_Exists()
	local name = ccRS.DeathKnight_RisenAlly
	local iDescriptor = ccRS.DeathKnight_RisenAllyDescriptor
	if name == nil then name = "Risen Ally" end
	if iDescriptor == nil then iDescriptor = "0x48" end
	for i = 0, # ccrObjectListTable do
		local TableObject = ccrObjectListTable[i]
		if TableObject ~= nil
		and TableObject:Exists()
		and TableObject:GetName() == name
		and TableObject:GetInt64Descriptor(iDescriptor) == Player:GetGUID()
		then
			-- Found it
			return true
		end
	end
	-- Not found
	return false
end
function ccR_DeathKnight_RequiresBloodBoil()
	if ccrTargetIsWithinDistance(10)
	and (vLastBloodBoilCheck == nil or (GetTime()-vLastBloodBoilCheck > 0.5))
	then
		objTable = Target:GetNearbyEnemies(10)
		for i = 1, # objTable do
			if objTable[i] ~= nil
			and not objTable[i]:IsDead()
			and objTable[i]:GetCreatureInfo() ~= "Totem"
			and objTable[i]:GetCreatureInfo() ~= "Critter"
			and objTable[i]:GetCreatureInfo() ~= "Wild Pet"
			and (objTable[i]:GetAura("Blood Plague") == nil or objTable[i]:GetAura("Frost Fever") == nil)
			then
				vLastBloodBoilCheck = GetTime()
				return true
			end;
		end
		vLastBloodBoilCheck = GetTime()
		return false
	else
		vLastBloodBoilCheck = GetTime()
		return false
	end;
end	

function ccR_DeathKnight_DeathStrike()
	local vDeathStrikeHP
	local vDeathStrikeOnProc
	local vDeathStrikeOnProcHP
	local vUseDeathStrike
	vUseDeathStrike = ccRS.DeathKnight_UseDeathStrike
	vDeathStrikeHP = ccRS.DeathKnight_DeathStrikeHP
	vDeathStrikeOnProc = ccRS.DeathKnight_DeathStrikeOnProc
	vDeathStrikeOnProcHP = ccRS.DeathKnight_DeathStrikeOnProcHP

	if vUseDeathStrike then
		-- Use Death Strike if below a certain % of health
		if ccrSpellCanAttack("Death Strike")
		and ccrPlayerHealth() <= vDeathStrikeHP
		and SpellCanAttack("Death Strike")
		then
			ccrCastAttack("Death Strike")
			return
		end
		return
	end

	if vDeathStrikeOnProc then
		if ccrPlayerHealth() <= vDeathStrikeOnProcHP
		and ccrPlayerHasBuff("Dark Succor")
		and ccrSpellCanAttack("Death Strike")
		then
			ccrCastAttack("Death Strike")
			return
		end
		return
	end

end

function ccR_DeathKnight_RaiseDead()
	local vRaiseDead = nil
	local vRaiseDeadOnBuffs = nil
	vRaiseDead = ccRS.DeathKnight_UseRaiseDead 
	vRaiseDeadOnBuffs = ccRS.DeathKnight_UseRaiseDeadOnBuffs

	if vRaiseDead
	or (vRaiseDeadOnBuffs and (ccrPlayerHasBuff("Pillar of Frost") or ccrPlayerHasBuff("Heroism") or ccrPlayerHasBuff("Bloodlust") or ccrPlayerHasBuff("Time Warp")))
	and SpellIsReady("Raise Dead")
	and ccrPlayerIsInCombat()
	then
		ccrCast("Raise Dead")
		return
	end
	return
end

--[[
	FROST
]]
function ccR_DeathKnight_PillarOfFrost()
	if ccRS.DeathKnight_2_UsePillarOfFrost
	and ccrPlayerHasSpell("Pillar of Frost")
	and SpellIsReady("Pillar of Frost")
	and ccrPlayerIsInCombat()
	and ccrTargetIsWithinMeleeRange()
	then
		ccrCast("Pillar of Frost")
		return
	end
	return
end